//
//  YXFeatureView.m
//  NewFeature
//
//  Created by mac on 15-3-29.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "YXFeatureView.h"
#import "YXModle.h"

@interface YXFeatureView ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *animation;
@property (weak, nonatomic) IBOutlet UIImageView *background;
@property (weak, nonatomic) IBOutlet UIImageView *guid;
@property (weak, nonatomic) IBOutlet UIImageView *largeText;
@property (weak, nonatomic) IBOutlet UIImageView *smallText;
@property (weak, nonatomic) IBOutlet UIButton *btnImge;

- (IBAction)btnClick:(id)sender;


@property (nonatomic, assign) BOOL stopLayout;

@end

@implementation YXFeatureView

- (void)setImages:(YXModle *)images
{
    _images = images;
    self.background.image = [UIImage imageNamed:_images.bkImage];
    self.guid.image = [UIImage imageNamed:_images.guiImge];
    self.largeText.image = [UIImage imageNamed:_images.larImage];
    self.smallText.image = [UIImage imageNamed:_images.smaImage];
  
}

-(void)setTg:(NSInteger)tg
{
    _tg = tg;
    if (_tg == self.maxCount - 1) {
        self.btnImge.hidden = NO;
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    if (self.stopLayout) {
        return;
    }
    if (self.tg == 0) {
        return;
    }
    self.animation.constant += [UIScreen mainScreen].bounds.size.width;
    
    
}

- (void)startAnimation:(BOOL) stopLayout
{
    self.stopLayout = stopLayout;
//    if (self.tg == self.maxCount - 1) {
//        self.btnImge.hidden = NO;
//    }
    
    [UIView animateWithDuration:0.5 animations:^{
        self.animation.constant = 0;
        [self layoutIfNeeded];
        //[self setNeedsLayout];
    } completion:^(BOOL finished) {
           }];

}

+ (instancetype)loadXib
{
    return [[[NSBundle mainBundle] loadNibNamed:@"YXFeatureView" owner:nil options:nil] lastObject];
}


- (IBAction)btnClick:(id)sender {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"chooseRootController" object:nil];
}
@end
